window.onload=function ()
{
    var arrayImage=["../picture/part2/paint1.jpeg","../picture/part2/paint2.png","../picture/part2/paint3.png","../picture/part2/paint4.png","../picture/part2/paint5.png","../picture/part2/paint6.jpg"];

    var i=0;//图片顺序标志


    var img=get('paint')//获取图片元素
    var arrowLeft=get('arrowLeft')//获取左侧按钮
    var arrowRight=get('arrowRight')//获取右侧按钮
    var name='circle';

    get(name+0).onclick=function ()
    {
        clickCircle(0);
    }
    get(name+1).onclick=function ()
    {
       clickCircle(1);
    }
    get(name+2).onclick=function ()
    {
        clickCircle(2);
    }
    get(name+3).onclick=function ()
    {
        clickCircle(3);
    }
    get(name+4).onclick=function ()
    {
        clickCircle(4);
    }
    get(name+5).onclick=function ()
    {
        clickCircle(5);
    }

    function clickCircle(number)
    {
        changeCircle(i,number);
        i=number;
    }

    function get(id)
    {
        return document.getElementById(id);
    }
    //箭头按钮控制
    arrowLeft.onclick=function left()
    {
        var flag=i;
        if(i>0)//若标志大于0，则减一
        {
            i--;
        }
        else //若标志等于0，则赋值5
        {
            i=5;
        }
        changeCircle(flag,i);
    }

    arrowRight.onclick=function right()
    {
        var flag=i;
        if(i<5)
        {
            i++;
        }
        else
        {
            i=0;
        }
        changeCircle(flag,i);

    }
    //切换圆点的方法
    function changeCircle(flag,i)
    {
        var nowCircle=get('circle'+flag);
        var nextCircle=get('circle'+i);
        nowCircle.style.backgroundColor='transparent';
        nextCircle.style.backgroundColor='white';
        img.src=arrayImage[i];
        clearInterval(time);
        time=setInterval(arrowRight.onclick,3000);
    }
    var time=setInterval(arrowRight.onclick,3000);

}